package com.vernhe;

import com.vernhe.circle.CircleLinkedList;
import com.vernhe.circle.SingleCircleLinkedList;
import com.vernhe.single.SingleLinkedList;

public class Main {

    static void testList(List<Integer> list) {
        list.add(11);
        list.add(22);
        list.add(33);
        list.add(44);
//        System.out.println(com.vernhe.list);
//        System.out.println(com.vernhe.list.get(0));
//        System.out.println(com.vernhe.list.get(com.vernhe.list.size()-1));
//        System.out.println(com.vernhe.list.remove(0));
//        System.out.println(com.vernhe.list);
//        System.out.println(com.vernhe.list.contains(22));

        list.add(0,55);
        list.add(2,66);
        list.add(list.size(),77);

        list.remove(0);
        list.remove(2);
        list.remove(list.size() - 1);

        Asserts.test(list.indexOf(44) == 3);
        Asserts.test(list.indexOf(22) == List.ELEMENT_NOT_FOUND);
        Asserts.test(list.contains(33));
        Asserts.test(list.get(0) == 11);
        Asserts.test(list.get(1) == 66);
        Asserts.test(list.get(list.size()-1) == 44);

        System.out.println(list);
    }

    static void Solution() {
        CircleLinkedList<Integer> list = new CircleLinkedList<>();
        for (int i = 0; i < 8; i++) {
            list.add(i);
        }
        list.reset();

        while (!list.isEmpty()) {
            list.next();
            list.next();
            System.out.println(list.remove());
        }
    }

    public static void main(String[] args) {
//        List<Integer> com.vernhe.list = new ArrayList2<>();
//
//        for (int i = 0; i <50; i++) {
//            com.vernhe.list.add(i);
//        }
//        for (int i = 0; i <50; i++) {
//            com.vernhe.list.remove(0);
//        }
//        testList(new LinkedList<>());
//        testList(new ArrayList<>());
//        testList(new SingleCircleLinkedList<>());
//        testList(new CircleLinkedList<>());
        Solution();

    }
}
